/*!
 * \file tfrconfig_set_int.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frconfig.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    int i_ret = 0;

    i_ret = frconfig_set_string((char *)"t_frconfig/t_frconfig_set_int/test9.txt",(char *)"time",NULL);
    CU_ASSERT_EQUAL(i_ret,FR_FAIL);

    return;
}

static void __case2(void)
{
    int i_ret = 0;

    i_ret = frconfig_set_string((char *)"t_frconfig/t_frconfig_set_int/test9.txt",NULL,(char *)"20");
    CU_ASSERT_EQUAL(i_ret,FR_FAIL);

    return;
}

static void __case3(void)
{
    int i_ret = 0;

    i_ret = frconfig_set_string(NULL,(char *)"time",(char *)"20");
    CU_ASSERT_EQUAL(i_ret,FR_FAIL);

    return;
}

static void __case4(void)
{
    int i_ret = 0;
    int i_value = 0;

    system("cp t_frconfig/t_frconfig_set_int/test9.txt t_frconfig/t_frconfig_set_int/test.txt");

    i_ret = frconfig_set_int((char *)"t_frconfig/t_frconfig_set_int/test.txt",(char *)"time",20);
    CU_ASSERT_EQUAL(i_ret,FR_SUCC);

    frconfig_get_int((char *)"t_frconfig/t_frconfig_set_int/test.txt",(char *)"time",&i_value);
    CU_ASSERT_EQUAL(i_value,20);
    return;
}

static void __case5(void)
{
    int i_ret = 0;
    int i_value = 0;

    system("cp t_frconfig/t_frconfig_set_int/test9.txt t_frconfig/t_frconfig_set_int/test.txt");

    i_ret = frconfig_set_int((char *)"t_frconfig/t_frconfig_set_int/test.txt",(char *)"age",20);
    CU_ASSERT_EQUAL(i_ret,FR_SUCC);

    frconfig_get_int((char *)"t_frconfig/t_frconfig_set_int/test.txt",(char *)"age",&i_value);
    CU_ASSERT_EQUAL(i_value,20);
    return;
}

int add_suite_frconfig_set_int(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frcomm frconfig_set_int()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);
    CU_add_test(pSuite, "case5", __case5);

    return FR_SUCC;
}
